"""
@Time ： 2022/12/2 9:08
@Auth ： 陈杰 200320501042
@E-mail : 1612845322@qq.com
"""
from pymysql import *

conn = connect(host="localhost", port=3306, user='root', password="cj2001..",db="bookstore", charset='utf8')

sql = '''
INSERT INTO books(书名, 作者, 出版社, 出版日期, 定价)
VALUES ('%s', '%s', '%s','%s', %f)
'''
cursor = conn.cursor()
while 1:
    title = input("输入书名（0=退出）：")
    if title == "0":
        break
    author = input("输入作者：")
    press = input("输入出版社：")
    pub_data = input("输入出版日期：")
    price = float(input("输入定价："))
    cursor.execute(sql % (title, author, press, pub_data, price))
cursor.close()
conn.commit()
conn.close()
